<?php
namespace Home\Common\Model;
use Think\Model\RelationModel;
class CommonModel extends RelationModel
{
    //查询单条数据
    public function getOne($arr)
    {
        return $this->where($arr)->find();
    }

    //添加数据
    public function getUserAdd($arr)
    {
        return $this->add($arr);
    }

    //查询所有数据
    public function getAll($arr = array(), $order = array())
    {
        return $this->where($arr)->order($order)->select();
    }
    //计算总数
    public function countSum($where = array())
    {
        $arr = $this->where($where)->count();
        return $arr;
    }

    //数据更新
    public function getEdit($arr)
    {
        return $this->save($arr);
    }
    //添加
    public function insert($map = array())
    {
        $id = $this->add($map);
        return $id;
    }

    //修改
    public function edit($map = array())
    {
        $result = $this->save($map);
        return $result;
    }

    //删除
    public function del($where = array())
    {
        $result = $this->where($where)->delete();
        return $result;
    }
    //加法
    public function inc($where = array(),$colum,$num){
        $result = $this->where($where)->setInc($colum,$num);
        return $result;
    }
    //减法
    public function dec($where = array(),$colum="",$num=""){
        $this->where($where)->setDec($colum,$num);
    }
}